package com.yenlien.traceyun.plant.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.yenlien.traceyun.business.interceptor.UserAuthUtil;
import com.yenlien.traceyun.plant.service.SearchService;
import com.yenlien.traceyun.webase.controller.BaseController;
import com.yenlien.traceyun.webase.utils.CheckParams;

/**
 * 追溯查询控制层
 *
 * @author maybe
 * @date 2020年10月27日
 */
@RestController
@RequestMapping("/search")
public class SearchController extends BaseController {
    @Autowired
    private SearchService searchService;

    //根据类型查询下拉
    @RequestMapping(value = "/findSelect", method = RequestMethod.POST)
    public Object findSelect(@RequestBody JSONObject params) {
        CheckParams.checkJson(params, new String[]{"type"});
        params.put("companyId", UserAuthUtil.getLoginUser().getCompanyId());
        return success(searchService.findSelect(params));
    }

    //根据条件分页查询选择项
    @PostMapping(value = "/findList")
    public Object findList(@RequestBody JSONObject params) {
        params.put("companyId", UserAuthUtil.getLoginUser().getCompanyId());
        return searchService.findList(params);
    }
}
